import React, { useState} from 'react'
import Header from '../../components/header/Header'
import img from '../../assets/img/log.png'
import './register.css'
import { reqRegister } from '../../request/api'
export default function Login(props) {
  const [user, setUser] = useState({ phone: "", password: "", nickname: "" });

  const zhuce = () => {
    reqRegister(user).then((res) => {
      if (res.data.code === 200) {
        props.history.push("/login");
      }
    });
  };
  return (
    <div>
      <Header title='注册'></Header>
      <div className="login">
          <div className="content">
            <img src={img} alt="" />
            <div>
              <input type="text" placeholder='手机号' value={user.phone}  onChange={(e) => setUser({ ...user, phone: e.target.value })}/>
            </div>
            <div>
              <input type="text" placeholder='昵  称' value={user.nickname}  onChange={(e) => setUser({ ...user, nickname: e.target.value })}/>
            </div>
            <div>
              <input type="text" placeholder='密   码' value={user.password}   onChange={(e) => setUser({ ...user, password: e.target.value })}/>
            </div>
            <button onClick={()=>zhuce()}>注册</button>
          </div>
        </div>
    </div>
  )
}
